<template>
  <section>
    <b-spinner v-if="loading" variant="primary" type="grow" label="Spinning" />
    <div>
      <h4 class="title">
        {{ defData.title }}
      </h4>
      <div class="an-cont">
        <div v-html="defData.content"></div>
      </div>
    </div>
  </section>
</template>

<script>
export default {
  data() {
    return {
      defData: {},
      id_number: "",
      loading: false
    };
  },
  asyncData({ app, query }) {
    const qs = require("qs");
    return app.$axios
      .post(
        `/anfile/php/an_ranweb.php`,
        qs.stringify({
          q: "articleinfo",
          data: {
            id_number: query.id
          }
        })
      )
      .then(res => {
        return { defData: res.data.data };
      });
  },
  mounted() {
    // this.anLoad();
  },
  methods: {
    anLoad() {
      this.id_number = this.$route.query.id;
      this.getData();
    },
    getData() {
      this.loading = true;
      this.$apiArticleInfo(this.id_number).then(res => {
        this.loading = false;
        this.defData = res.data.data;
      });
    }
  }
};
</script>
